﻿@model Opds4Net.Web.Models.Book
        <script type="text/javascript" src="../../Scripts/Common/Url.js"></script>
        <script type="text/javascript">
             function navigate(a) {
                 self.location = changeUrlParameter(self.location, 'leaf', a);
             }
        </script>

        <div class="editor-label">
            @Html.LabelFor(model => model.Categories)
            @Html.CheckBox("checkLeafNode", (bool)ViewBag.LeafNodeOnly, new { onClick =  @String.Format("navigate('{0}')", !(bool)ViewBag.LeafNodeOnly) }) Only shows leaf node.
        </div>

        <div class="editor-field">
            <table style="width: 100%">
                <tr>
                    @{
                        int cnt = 0;
                        IEnumerable<Opds4Net.Web.Models.PickerCategory> categories = ViewBag.Categories;

                        foreach (var category in categories)
                        {
                            if (cnt++ % 3 == 0) {
                                @:  </tr> <tr> 
                            }
                            @: <td> 
                                <input type="checkbox" 
                                       name="selectedCategories" 
                                       value="@category.Id"
                                       @(Html.Raw(Model != null && Model.Categories != null && Model.Categories.Any(c => c.Id == category.Id) ? "checked=\"checked\"" : "")) /> 
                                @category.FullName
                            @:</td>
                        }
                        @: </tr>
                    }
            </table>
        </div>